﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:mmkit="clr-namespace:MM.Toolkit;assembly=MM.Toolkit"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:local="clr-namespace:MM.Toolkit.Tester"
             x:Class="MM.Toolkit.Tester.MainPage"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <mmkit:DateTimeTextConverter x:Key="DateTimeTextConverter" />
        <local:SearchItemTextConverter x:Key="SearchItemTextConverter" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel Orientation="Vertical"
                    HorizontalAlignment="Left"
                    Margin="6">
            <TextBlock Text="DateTimeBox"
                       FontWeight="SemiBold"
                       Margin="2" />
            <StackPanel Orientation="Horizontal">
                <StackPanel Orientation="Vertical">
                    <mmkit:DateTimeBox SelectedDateTime="{Binding Path=TestDate, Mode=TwoWay}"
                                       DateButtonIsVisible="{Binding Path=DateButtonIsVisible, Mode=OneWay}"
                                       TimeButtonIsVisible="{Binding Path=TimeButtonIsVisible, Mode=OneWay}"
                                       UpDownButtonsIsVisible="{Binding Path=UpDownButtonsIsVisible, Mode=OneWay}"
                                       DateFormat="{Binding Path=DateFormat, Mode=OneWay}" />
                    <TextBlock Text="{Binding Path=TestDate, Mode=OneWay, Converter={StaticResource DateTimeTextConverter}, ConverterParameter='yyyy.MM.dd HH:mm'}" />
                </StackPanel>
                <StackPanel Orientation="Vertical"
                            Margin="12,0,0,0">
                    <CheckBox IsChecked="{Binding Path=DateButtonIsVisible, Mode=TwoWay}"
                              Content="Show date selector button"
                              Margin="0,3,0,0" />
                    <CheckBox IsChecked="{Binding Path=TimeButtonIsVisible, Mode=TwoWay}"
                              Content="Show time selector button"
                              Margin="0,3,0,0" />
                    <CheckBox IsChecked="{Binding Path=UpDownButtonsIsVisible, Mode=TwoWay}"
                              Content="Show up/down buttons"
                              Margin="0,3,0,0" />
                    <TextBox Text="{Binding Path=DateFormat, Mode=TwoWay}"
                             Margin="0,0,0,0" />
                </StackPanel>
            </StackPanel>

            <TextBlock Text="SearchBox"
                       FontWeight="SemiBold"
                       Margin="2,12,2,2" />
            <StackPanel Orientation="Horizontal">
                <StackPanel Orientation="Vertical">
                    <mmkit:SearchBox x:Name="CarSearchBox"
                                     ClearContent="- Choose blank -"
                                     SearchLabelText="Search for an item"
                                     SearchText="{Binding Path=SearchText, Mode=TwoWay}"
                                     SearchStartedCommand="{Binding Path=SearchStartedCommand, Mode=OneWay}"
                                     ItemsSource="{Binding Path=SearchItems, Mode=OneWay}"
                                     SelectedItem="{Binding Path=SelectedSearchItem, Mode=TwoWay}"
                                     TextConverter="{StaticResource SearchItemTextConverter}"
                                     PopupWidth="400" PopupHeight="300"
                                     Width="170">
                        <mmkit:SearchBox.ContentTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal"
                                            Margin="4,2,2,2">
                                    <TextBlock Text="{Binding Path=Brand}"
                                               FontWeight="SemiBold"
                                               Margin="0,0,4,0"/>
                                    <TextBlock Text="{Binding Path=Model}"
                                               Foreground="SteelBlue" />
                                </StackPanel>
                            </DataTemplate>
                        </mmkit:SearchBox.ContentTemplate>
                        <mmkit:SearchBox.NullContentTemplate>
                            <DataTemplate>
                                <TextBlock Text="Choose a car..." FontStyle="Italic" Foreground="DimGray" Margin="4,2,2,2" />
                            </DataTemplate>
                        </mmkit:SearchBox.NullContentTemplate>
                        <mmkit:SearchBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Path=Brand}" Width="100" TextTrimming="WordEllipsis" ToolTipService.ToolTip="{Binding Path=Name}" />
                                    <TextBlock Text="{Binding Path=Model}" Foreground="SlateGray" />
                                </StackPanel>
                            </DataTemplate>
                        </mmkit:SearchBox.ItemTemplate>
                    </mmkit:SearchBox>
                    <StackPanel Orientation="Horizontal"
                                Margin="0,6,0,0">
                        <TextBlock Text="Selected car : " />
                        <TextBlock Text="{Binding Path=SelectedSearchItem, Mode=OneWay, Converter={StaticResource SearchItemTextConverter}, TargetNullValue='None'}"
                                   Foreground="DimGray"/>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
